#include "data_flood.h"
#include <time.h>

struct timespec time_to_wait;

uint64 get_current_time(void)
{
	uint64 result = 0;

	(void)clock_gettime(CLOCK_MONOTONIC, &time_to_wait);
	result += time_to_wait.tv_sec * DF_TIME_NANOSES_PER_S;
	result += time_to_wait.tv_nsec;

	return result;
}

uint64 time_diff_s(uint64 st, uint64 et)
{
	if(et < st)
		df_error("[time_diff_s]et=%lu, et=%lu", st, et);
	
	return (et - st) / DF_TIME_NANOSES_PER_S;
}

uint64 time_diff_ns(uint64 st, uint64 et)
{
	if(et < st)
		df_error("[time_diff_s]et=%lu, et=%lu", st, et);
	
	return (et - st);
}